<?php

namespace Addons\Report\Controller;

use Home\Controller\AddonsController;
use Admin\Builder\AdminListBuilder;
use Admin\Builder\AdminConfigBuilder;
use Admin\Builder\AdminTreeListBuilder;
require_once(ONETHINK_ADDON_PATH . 'Report/Common/function.php');


class ReportController extends AddonsController
{
    /**
     * 获取管理员配置参数
     */
    public function eject()
    {
        parse_str(I('get.param'), $param);
        $this->assign('param', $param);
        if (is_login()) {
            $config = _getAddonsCinfig();
            $this->assign("reason", $config);
            $this->display(T('Addons://Report@Report/eject'));
        }
    }

    /**
     * 对举报的信息进行数据库写入操作
     */
    public function addReport()
    {
        $preason = I('post.reason', '', 'op_t');
        $pcontent = I('post.content', '', 'op_t');
        $purl = I('post.url', '', 'op_t');
        $ptype = I('post.type', '', 'op_t');
        $pdata = I('post.data', '', 'op_t');

        $data['uid'] = is_login();
        $data['url'] = $purl;
        $data['reason'] = $preason;        //  举报原因
        $data['content'] = $pcontent;      // 举报描述
        $data['type'] = $ptype;
        $data['data'] = $pdata;
        $result = D('Addons://Report/Report')->addData($data);
        if ($result) {
            $this->success('举报成功', 0);
        } else {
            $this->error('举报失败');
        }
    }








}